#!/usr/bin/env ruby
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
begin
  require 'rubygems' 
rescue LoadError
end
require 'pathname'

#p ARGV[0]
cmdString = "cmake -G \"MinGW Makefiles\" " + ARGV.join(" ")
puts cmdString
system(cmdString)

logFileName = "CMake2TC_import.log"

cmdString = "mingw32-make -n -i> "
cmdString += logFileName
system(cmdString)

logFilePath = Pathname.new(logFileName)
File.open(logFilePath) do |fp| 
	fp.each do |line| 
		if /g\+\+/ =~ line then
			cmdArray = line.scan(/g\+\+.*/)
			puts cmdArray[0]
		end
		if /gcc/ =~ line then
			line
		end
	end
end
